package collection;

import java.util.*;

public class CollectionOperDemo {
    public static void main(String[] args) {
        Collection<String> c1 = new ArrayList<>();
        Collections.addAll(c1, "java", "c++", ".net");
        System.out.println("c1:" + c1);

        Collection<String> c2 = new ArrayList<>();
        c2.add("android");
        c2.add("ios");
        c2.add("java");
        System.out.println("c2:" + c2);
        System.out.println("-----------------------------------");

        c1.addAll(c2);
        System.out.println("c1:" + c1);
        System.out.println("c1:" + c2);
        System.out.println("-----------------------------------");

        Collection<String> c3 = new ArrayList<>();
        c3.add("java");
        c3.add("android");
        c3.add("php");
        for (String s : c3) {
            System.out.println(s);
        }
        System.out.println("上面是list,下面是hashset");

        HashSet<String> hs = new HashSet<>();
        hs.add("c++");
        hs.add("c++");
        hs.add("android");
        hs.add("c");
        hs.add("php");
        for (String h : hs) {
            System.out.println(h);
        }
        System.out.println("-------------");
        System.out.println(c1.contains(c3));
 /*       c1.retainAll(c3);
        System.out.println("c1:"+c1); //c++, android
        System.out.println("c3:"+c3); */
        c1.removeAll(c3);
        System.out.println(c1);//[c++, .net, ios]

    }
}
